package trunk.src.levelUp.Library;

import java.util.Iterator;
import java.util.List;

/**
 * Created by user on 19.01.14.
 */
public class BookManager {
    private BookStorage bookStorage;

    public BookManager() {
        bookStorage = new BookStorage();
    }

    public Book getBookById(int id) {

    }

    public Book getBookByName(String name) {
        List<Book> all = bookStorage.getAllBook();
        Iterator<Book> iter = all.iterator();
        Book tmp;
        while (iter.hasNext()){
            tmp = iter.next();
            if(tmp.getName().equals(name))
                return tmp;
        }
        return null;
    }

    public List<Book> getBooksByAuthor(String author){

    }

    public void addBook(String name,String author){
        int newId = bookStorage.getNextIdForBook();
        Book newBook = new Book(newId,name,author);
        bookStorage.addBookToStorage(newBook);
    }


}
